﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

using GreyGate.Kinect;
using GreyGate.Utils;

namespace GreyGate.Screens
{
    public enum GameState
    {
        Menu, Play, Pause, End
    }

    class ScreenManager : DrawableGameComponent
    {
        public  static  GameState   gameState = GameState.Menu;
        private         SpriteFont  spriteFont;
        private         bool        isExiting = false;

        private         SpriteBatch           spriteBatch;
        private         ContentManager        content;
        private         GraphicsDeviceManager graphics;

        public  static  Keyboard    kb;

        private         MenuScreen  menuScreen;
        private         GameScreen  gameScreen;
        private         PauseScreen pauseScreen;
        private         EndScreen   endScreen;

        private         KinectMoveDetection kinectUtil;


        public ScreenManager(Game game, ContentManager content, SpriteBatch spriteBatch,
                             GraphicsDeviceManager graphics, KinectMoveDetection kinectUtil)
            : base(game)
        {
            this.content = content;
            this.spriteBatch = spriteBatch;
            this.graphics = graphics;
            this.kinectUtil = kinectUtil;
            initialize();
        }

        public void initialize()
        {
            kb = new Keyboard();

            menuScreen = new MenuScreen(content, graphics, kinectUtil);
            gameScreen = new GameScreen(content,kinectUtil, graphics);
        }

        /*public void LoadContent()
        {

        }*/
        override
        public void Update(GameTime gameTime)
        {
            kb.Update();
            // updatet die entsprechenden Screens
            switch (gameState)
            {
                case GameState.Menu:
                    menuScreen.update(gameTime);
                    break;
                case GameState.Play:
                    gameScreen.update(gameTime);
                    break;
                case GameState.Pause:
                    pauseScreen.update(gameTime);
                    break;
                case GameState.End:
                    endScreen.update(gameTime);
                    break;
            }
            base.Update(gameTime);           
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            // zeichnet die entsprechenden Screens neu
            switch (gameState)
            {
                case GameState.Menu:
                    menuScreen.draw(spriteBatch);
                    break;
                case GameState.Play:
                    gameScreen.draw(spriteBatch);
                    break;
                case GameState.Pause:
                    pauseScreen.draw(spriteBatch);
                    break;
                case GameState.End:
                    endScreen.draw(spriteBatch);
                    break;
            }
            //base.Draw();
        }
    }
}
